/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs575.coresystem;

import java.sql.*;

/**
 * test
 * @author bms
 */
public class DBPool {
    /* Local database test */
    /* you should always work on this until the final phase */

    private static String url = "jdbc:mysql://localhost:3306/";
    private static String dbName = "tasks_management";
    private static String driver = "com.mysql.jdbc.Driver";
    private static String userName = "root";
    private static String password = "";
    /* Production database */
    /* You shouldn't use this database until the final test
    private static String url = "jdbc:mysql://67.20.97.227:3306/";
    private static String dbName = "alsulamy_tasks_management";
    private static String driver = "com.mysql.jdbc.Driver";
    private static String userName = "alsulamy_tasks"; 
    private static String password = "Fkuh5OLwf;vm";*/
    private static Connection conn = null;

    public static void initPool() {
        try {
            Class.forName(driver).newInstance();
        } catch (Exception e) {
        }
    }

    public static Connection getConnection() {
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url + dbName, userName, password);//conn.getClass().newInstance();
        } catch (Exception e) {
            System.out.println("Connection error!");
            conn = null;
        }
        return conn;
    }
   
    public static void closeConnection(Connection conn) 
        {
            if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ex) {
    //                Logger.getLogger(Authentication.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
